# Nginx
# Version 1.0

# docker container run -d --name web -p 8080:80 --mount type=bind,source=/Users/makeup1122/temp/docker,target=/usr/share/nginx/html,readonly  -v /Users/makeup1122/temp/docker/nginx/nginx.conf:/etc/nginx/nginx.conf nginx
# docker container run -d --name web -p 8080:80 --link php-fpm -v /Users/makeup1122/temp/docker/www/:/usr/share/nginx/html makeup1122/nginx
# docker container run -d --name web -p 8080:80 --network web-net -v /Users/makeup1122/temp/docker/www/:/usr/share/nginx/html makeup1122/nginx
# Only for Linux Host
# docker container run -d --name web --network host -v /Users/makeup1122/temp/docker/www/:/usr/share/nginx/html makeup1122/nginx
# docker container run -d --name web --network host -v /Users/makeup1122/temp/docker/www/:/usr/share/nginx/html -v /Users/makeup1122/temp/docker/nginx/conf.d/:/etc/nginx/conf.d/ makeup1122/nginx
# 后端和前端
# docker container run -d --name web --network web-net -v /Users/makeup1122/temp/docker/www/:/usr/share/nginx/html -v /Users/makeup1122/temp/docker/nginx/conf.d/:/etc/nginx/conf.d/ -p 8080:80 nginx:latest

# 2020-06-30
# docker run --rm --interactive --tty --volume $PWD:/app node:lts-alpine `npm install  --registry=https://registry.npm.taobao.org && npm run build`
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install --registry=https://registry.npm.taobao.org --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
COPY . .
COPY .env.docker .env.production
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
# COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY --from=0 /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
# command: [nginx-debug, '-g', 'daemon off;']
CMD ["nginx", "-g", "daemon off;"]
